gusucode.com > VC 电梯管理系统 > VC 电梯管理系统/gusucode/Elevator/MyTimer.cpp

    //Download by http://www.NewXing.com
// MyTimer.cpp: implementation of the CMyTimer class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MyTimer.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
CTimerMap CMyTimer::m_sTimeMap;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CMyTimer::CMyTimer()
{
	m_nTimerID = 0;
}

CMyTimer::~CMyTimer()
{

}

void CALLBACK CMyTimer::MyTimerProc(HWND hwnd,UINT uMsg,UINT idEvent,DWORD dwTime)
{
	CString sz;
	sz.Format("%d号定时器:%s",
		idEvent,
		m_sTimeMap[idEvent]->szContent);
	AfxMessageBox(sz);
}

void CMyTimer::SetMyTimer(UINT nElapse,CString sz)
{
	szContent = sz;
	m_nTimerID = SetTimer(NULL,NULL,nElapse,MyTimerProc);
	m_sTimeMap[m_nTimerID] = this;
}

void CMyTimer::KillMyTimer()
{
	KillTimer(NULL,m_nTimerID);
	m_sTimeMap.RemoveKey(m_nTimerID);
}